<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>积分明细</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta http-equiv="Cache-Control" content="no-transform">
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<link rel="stylesheet" href="style/css/basic.css" />
		<link rel="stylesheet" href="style/css/integral_subsidiary.css" />
		<script type="text/javascript" src="style/plugin/mui/js/mui.min.js"></script>
		<script type="text/javascript" src="style/js/jquery-1.8.3.min.js" ></script>
		<script type="text/javascript" src="style/mockjs/dist/mock.js"></script>
		<script type="text/javascript" src="style/js/vue.min.js"></script>
		<script type="text/javascript" src="style/js/vue-resource.js"></script>
		<script type="text/javascript" src="style/js/basic.js"></script>
	</head>
	<body>
		<div id="integralDetail">
		    <div id="header">
				<h1>积分明细</h1>
				<span class="backicon"></span>
			</div>
			<div style="padding-top: 50px;" class="tab">
				<ul class="tabcontent clearfix">
					<li :class="[left_tab,{active:flag}]" @tap="generate">生成明细</li>
					<li :class="[right_tab,{active:flag==false}]" @tap="exchange">兑换明细</li>
				</ul>
				<div>
					<div v-if="flag">
						<div class="intergral_list" v-for="(gen,index) in genList" v-if="genList!=''">
							<span class="time">{{fTime(gen.create_time)}}</span>
							<div class="up">
								<span class="text_color ">+<em>{{gen.score}}</em>积分</span>
								<span class="gray">{{gen.desc}}</span>
							</div>
						</div>
					</div>
					<div v-if="flag==false">
						<div class="intergral_list" v-for="(exc,index) in exList" v-if="exList!=''">
							<span class="time">{{fTime(exc.create_time)}}</span>
							<div class="up">
								<span class="text_color ">-<em>{{exc.score}}</em>积分</span>
								<span class="gray">{{exc.desc}}</span>
							</div>
						</div>
					</div>
				</div> 
			</div>
	
		</div>
		
	</body>
	<script>
        new Vue({
        	el:"#integralDetail",
        	data:{
        		flag:true,
        		left_tab:"left_tab",
        		right_tab:"right_tab",
        		genList:"",
        		exList:"",
        		ticket:"",
				sign:""
        	}, 
        	methods:{
        		generate:function(){
        			this.flag=true
        		},
        		exchange:function(){
                    this.flag=false        			
        		},
        		fTime:function(timestamp){
                	if (typeof timestamp == "undefined") {
				        timestamp = Math.round(new Date().getTime() / 1000)
				    }
				    var n = parseInt(timestamp) * 1000
				    var date = new Date(n);
				    var Y = date.getFullYear() + '-';
				    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
				    var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
				    var H=date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
				    var Min=date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
				    var S=date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
				    return (Y + M + D)
                }
        	},
        	created:function(){
        		this.ticket=localStorage.getItem("tick")
                this.sign=localStorage.getItem("sig")
        		//获取生成积分明细列表
        	    this.$http.post(domain+"/member/getScoreLogList?t="+this.ticket+"&sign="+this.sign,{page:1,type:1},{emulateJSON:true}).then(
		            function (res) {
		                // 处理成功的结果
		                console.log(res.body)	
		                if(res.body.code==1){
		                  
		                  this.genList=res.body.data.list;
		                } 
		            },function (res) {
		            // 处理失败的结果
		            console.log(res) 
		            }
		        );
		        //获取兑换积分明细列表
		        this.$http.post(domain+"/member/getScoreLogList?t="+this.ticket+"&sign="+this.sign,{page:1,type:2},{emulateJSON:true}).then(
		            function (res) {
		                // 处理成功的结果
		                console.log(res.body)	 
		                if(res.body.code==1){
		                  
		                  this.exList=res.body.data.list;
		                } 
		            },function (res) {
		            // 处理失败的结果
		            console.log(res) 
		            }
		        );
        	}
        })
	</script>

</html>